package parts5.lesson60;

import java.util.Observable;
import java.util.Observer;

public class House extends Observable {
    private double price;
    private String title;
    public House(double price,String title){
        this.price=price;
        this.title=title;
    }

    public double getPrice() {
        return price;
    }

    public void setPrice(double price) {
        if(price>this.price){
            //价格上涨了，我要通知买房者
            super.setChanged();
            //唤醒所有的观察者
            super.notifyObservers(price);
        }
        this.price = price;
    }

    @Override
    public String toString() {
        return this.title;
    }
}
